package bpmn.diagram.providers;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.ui.services.modelingassistant.ModelingAssistantProvider;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;

import bpmn.diagram.edit.parts.ComplexEditPart;
import bpmn.diagram.edit.parts.DataBasedEditPart;
import bpmn.diagram.edit.parts.DataObjectEditPart;
import bpmn.diagram.edit.parts.EndEditPart;
import bpmn.diagram.edit.parts.InclusiveEditPart;
import bpmn.diagram.edit.parts.IntermediateEditPart;
import bpmn.diagram.edit.parts.Lane2EditPart;
import bpmn.diagram.edit.parts.LaneCompartmentLaneEditPart;
import bpmn.diagram.edit.parts.LaneEditPart;
import bpmn.diagram.edit.parts.ParallelEditPart;
import bpmn.diagram.edit.parts.PoolCompartmentPoolEditPart;
import bpmn.diagram.edit.parts.PoolEditPart;
import bpmn.diagram.edit.parts.ProcessCompartmentProcessEditPart;
import bpmn.diagram.edit.parts.ProcessEditPart;
import bpmn.diagram.edit.parts.StartEditPart;
import bpmn.diagram.edit.parts.Task2EditPart;
import bpmn.diagram.edit.parts.Task3EditPart;
import bpmn.diagram.edit.parts.Task4EditPart;
import bpmn.diagram.edit.parts.Task5EditPart;
import bpmn.diagram.edit.parts.Task6EditPart;
import bpmn.diagram.edit.parts.Task7EditPart;
import bpmn.diagram.edit.parts.Task8EditPart;
import bpmn.diagram.edit.parts.Task9EditPart;
import bpmn.diagram.edit.parts.TaskEditPart;
import bpmn.diagram.part.Bpmn_1_1DiagramEditorPlugin;
import bpmn.diagram.part.Messages;

/**
 * @generated
 */
public class Bpmn_1_1ModelingAssistantProvider extends
		ModelingAssistantProvider {

	/**
	 * @generated
	 */
	public List getTypesForPopupBar(IAdaptable host) {
		IGraphicalEditPart editPart = (IGraphicalEditPart) host
				.getAdapter(IGraphicalEditPart.class);
		if (editPart instanceof ProcessEditPart) {
			ArrayList<IElementType> types = new ArrayList<IElementType>(1);
			types.add(Bpmn_1_1ElementTypes.Pool_2003);
			return types;
		}
		if (editPart instanceof PoolCompartmentPoolEditPart) {
			ArrayList<IElementType> types = new ArrayList<IElementType>(2);
			types.add(Bpmn_1_1ElementTypes.Process_3001);
			types.add(Bpmn_1_1ElementTypes.Lane_3007);
			return types;
		}
		if (editPart instanceof ProcessCompartmentProcessEditPart) {
			ArrayList<IElementType> types = new ArrayList<IElementType>(17);
			types.add(Bpmn_1_1ElementTypes.Task_3002);
			types.add(Bpmn_1_1ElementTypes.Task_3009);
			types.add(Bpmn_1_1ElementTypes.Task_3014);
			types.add(Bpmn_1_1ElementTypes.Task_3015);
			types.add(Bpmn_1_1ElementTypes.Task_3016);
			types.add(Bpmn_1_1ElementTypes.Task_3017);
			types.add(Bpmn_1_1ElementTypes.Task_3018);
			types.add(Bpmn_1_1ElementTypes.Task_3019);
			types.add(Bpmn_1_1ElementTypes.Task_3020);
			types.add(Bpmn_1_1ElementTypes.Start_3003);
			types.add(Bpmn_1_1ElementTypes.Intermediate_3004);
			types.add(Bpmn_1_1ElementTypes.End_3005);
			types.add(Bpmn_1_1ElementTypes.DataObject_3006);
			types.add(Bpmn_1_1ElementTypes.Inclusive_3010);
			types.add(Bpmn_1_1ElementTypes.Complex_3011);
			types.add(Bpmn_1_1ElementTypes.Parallel_3012);
			types.add(Bpmn_1_1ElementTypes.DataBased_3013);
			return types;
		}
		if (editPart instanceof LaneCompartmentLaneEditPart) {
			ArrayList<IElementType> types = new ArrayList<IElementType>(1);
			types.add(Bpmn_1_1ElementTypes.Lane_3008);
			return types;
		}
		return Collections.EMPTY_LIST;
	}

	/**
	 * @generated
	 */
	public List getRelTypesOnSource(IAdaptable source) {
		IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
				.getAdapter(IGraphicalEditPart.class);
		if (sourceEditPart instanceof PoolEditPart) {
			return ((PoolEditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof TaskEditPart) {
			return ((TaskEditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof Task2EditPart) {
			return ((Task2EditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof Task3EditPart) {
			return ((Task3EditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof Task4EditPart) {
			return ((Task4EditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof Task5EditPart) {
			return ((Task5EditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof Task6EditPart) {
			return ((Task6EditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof Task7EditPart) {
			return ((Task7EditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof Task8EditPart) {
			return ((Task8EditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof Task9EditPart) {
			return ((Task9EditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof StartEditPart) {
			return ((StartEditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof IntermediateEditPart) {
			return ((IntermediateEditPart) sourceEditPart)
					.getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof EndEditPart) {
			return ((EndEditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof DataObjectEditPart) {
			return ((DataObjectEditPart) sourceEditPart)
					.getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof InclusiveEditPart) {
			return ((InclusiveEditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof ComplexEditPart) {
			return ((ComplexEditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof ParallelEditPart) {
			return ((ParallelEditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof DataBasedEditPart) {
			return ((DataBasedEditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof LaneEditPart) {
			return ((LaneEditPart) sourceEditPart).getMARelTypesOnSource();
		}
		if (sourceEditPart instanceof Lane2EditPart) {
			return ((Lane2EditPart) sourceEditPart).getMARelTypesOnSource();
		}
		return Collections.EMPTY_LIST;
	}

	/**
	 * @generated
	 */
	public List getRelTypesOnTarget(IAdaptable target) {
		IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
				.getAdapter(IGraphicalEditPart.class);
		if (targetEditPart instanceof PoolEditPart) {
			return ((PoolEditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof TaskEditPart) {
			return ((TaskEditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof Task2EditPart) {
			return ((Task2EditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof Task3EditPart) {
			return ((Task3EditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof Task4EditPart) {
			return ((Task4EditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof Task5EditPart) {
			return ((Task5EditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof Task6EditPart) {
			return ((Task6EditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof Task7EditPart) {
			return ((Task7EditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof Task8EditPart) {
			return ((Task8EditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof Task9EditPart) {
			return ((Task9EditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof StartEditPart) {
			return ((StartEditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof IntermediateEditPart) {
			return ((IntermediateEditPart) targetEditPart)
					.getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof EndEditPart) {
			return ((EndEditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof DataObjectEditPart) {
			return ((DataObjectEditPart) targetEditPart)
					.getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof InclusiveEditPart) {
			return ((InclusiveEditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof ComplexEditPart) {
			return ((ComplexEditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof ParallelEditPart) {
			return ((ParallelEditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof DataBasedEditPart) {
			return ((DataBasedEditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof LaneEditPart) {
			return ((LaneEditPart) targetEditPart).getMARelTypesOnTarget();
		}
		if (targetEditPart instanceof Lane2EditPart) {
			return ((Lane2EditPart) targetEditPart).getMARelTypesOnTarget();
		}
		return Collections.EMPTY_LIST;
	}

	/**
	 * @generated
	 */
	public List getRelTypesOnSourceAndTarget(IAdaptable source,
			IAdaptable target) {
		IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
				.getAdapter(IGraphicalEditPart.class);
		IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
				.getAdapter(IGraphicalEditPart.class);
		if (sourceEditPart instanceof PoolEditPart) {
			return ((PoolEditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof TaskEditPart) {
			return ((TaskEditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof Task2EditPart) {
			return ((Task2EditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof Task3EditPart) {
			return ((Task3EditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof Task4EditPart) {
			return ((Task4EditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof Task5EditPart) {
			return ((Task5EditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof Task6EditPart) {
			return ((Task6EditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof Task7EditPart) {
			return ((Task7EditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof Task8EditPart) {
			return ((Task8EditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof Task9EditPart) {
			return ((Task9EditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof StartEditPart) {
			return ((StartEditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof IntermediateEditPart) {
			return ((IntermediateEditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof EndEditPart) {
			return ((EndEditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof DataObjectEditPart) {
			return ((DataObjectEditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof InclusiveEditPart) {
			return ((InclusiveEditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof ComplexEditPart) {
			return ((ComplexEditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof ParallelEditPart) {
			return ((ParallelEditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof DataBasedEditPart) {
			return ((DataBasedEditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof LaneEditPart) {
			return ((LaneEditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		if (sourceEditPart instanceof Lane2EditPart) {
			return ((Lane2EditPart) sourceEditPart)
					.getMARelTypesOnSourceAndTarget(targetEditPart);
		}
		return Collections.EMPTY_LIST;
	}

	/**
	 * @generated
	 */
	public List getTypesForSource(IAdaptable target,
			IElementType relationshipType) {
		IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
				.getAdapter(IGraphicalEditPart.class);
		if (targetEditPart instanceof PoolEditPart) {
			return ((PoolEditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof TaskEditPart) {
			return ((TaskEditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof Task2EditPart) {
			return ((Task2EditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof Task3EditPart) {
			return ((Task3EditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof Task4EditPart) {
			return ((Task4EditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof Task5EditPart) {
			return ((Task5EditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof Task6EditPart) {
			return ((Task6EditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof Task7EditPart) {
			return ((Task7EditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof Task8EditPart) {
			return ((Task8EditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof Task9EditPart) {
			return ((Task9EditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof StartEditPart) {
			return ((StartEditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof IntermediateEditPart) {
			return ((IntermediateEditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof EndEditPart) {
			return ((EndEditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof DataObjectEditPart) {
			return ((DataObjectEditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof InclusiveEditPart) {
			return ((InclusiveEditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof ComplexEditPart) {
			return ((ComplexEditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof ParallelEditPart) {
			return ((ParallelEditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof DataBasedEditPart) {
			return ((DataBasedEditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof LaneEditPart) {
			return ((LaneEditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		if (targetEditPart instanceof Lane2EditPart) {
			return ((Lane2EditPart) targetEditPart)
					.getMATypesForSource(relationshipType);
		}
		return Collections.EMPTY_LIST;
	}

	/**
	 * @generated
	 */
	public List getTypesForTarget(IAdaptable source,
			IElementType relationshipType) {
		IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
				.getAdapter(IGraphicalEditPart.class);
		if (sourceEditPart instanceof PoolEditPart) {
			return ((PoolEditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof TaskEditPart) {
			return ((TaskEditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof Task2EditPart) {
			return ((Task2EditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof Task3EditPart) {
			return ((Task3EditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof Task4EditPart) {
			return ((Task4EditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof Task5EditPart) {
			return ((Task5EditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof Task6EditPart) {
			return ((Task6EditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof Task7EditPart) {
			return ((Task7EditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof Task8EditPart) {
			return ((Task8EditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof Task9EditPart) {
			return ((Task9EditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof StartEditPart) {
			return ((StartEditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof IntermediateEditPart) {
			return ((IntermediateEditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof EndEditPart) {
			return ((EndEditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof DataObjectEditPart) {
			return ((DataObjectEditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof InclusiveEditPart) {
			return ((InclusiveEditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof ComplexEditPart) {
			return ((ComplexEditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof ParallelEditPart) {
			return ((ParallelEditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof DataBasedEditPart) {
			return ((DataBasedEditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof LaneEditPart) {
			return ((LaneEditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		if (sourceEditPart instanceof Lane2EditPart) {
			return ((Lane2EditPart) sourceEditPart)
					.getMATypesForTarget(relationshipType);
		}
		return Collections.EMPTY_LIST;
	}

	/**
	 * @generated
	 */
	public EObject selectExistingElementForSource(IAdaptable target,
			IElementType relationshipType) {
		return selectExistingElement(target,
				getTypesForSource(target, relationshipType));
	}

	/**
	 * @generated
	 */
	public EObject selectExistingElementForTarget(IAdaptable source,
			IElementType relationshipType) {
		return selectExistingElement(source,
				getTypesForTarget(source, relationshipType));
	}

	/**
	 * @generated
	 */
	protected EObject selectExistingElement(IAdaptable host, Collection types) {
		if (types.isEmpty()) {
			return null;
		}
		IGraphicalEditPart editPart = (IGraphicalEditPart) host
				.getAdapter(IGraphicalEditPart.class);
		if (editPart == null) {
			return null;
		}
		Diagram diagram = (Diagram) editPart.getRoot().getContents().getModel();
		HashSet<EObject> elements = new HashSet<EObject>();
		for (Iterator<EObject> it = diagram.getElement().eAllContents(); it
				.hasNext();) {
			EObject element = it.next();
			if (isApplicableElement(element, types)) {
				elements.add(element);
			}
		}
		if (elements.isEmpty()) {
			return null;
		}
		return selectElement((EObject[]) elements.toArray(new EObject[elements
				.size()]));
	}

	/**
	 * @generated
	 */
	protected boolean isApplicableElement(EObject element, Collection types) {
		IElementType type = ElementTypeRegistry.getInstance().getElementType(
				element);
		return types.contains(type);
	}

	/**
	 * @generated
	 */
	protected EObject selectElement(EObject[] elements) {
		Shell shell = Display.getCurrent().getActiveShell();
		ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
				Bpmn_1_1DiagramEditorPlugin.getInstance()
						.getItemProvidersAdapterFactory());
		ElementListSelectionDialog dialog = new ElementListSelectionDialog(
				shell, labelProvider);
		dialog.setMessage(Messages.Bpmn_1_1ModelingAssistantProviderMessage);
		dialog.setTitle(Messages.Bpmn_1_1ModelingAssistantProviderTitle);
		dialog.setMultipleSelection(false);
		dialog.setElements(elements);
		EObject selected = null;
		if (dialog.open() == Window.OK) {
			selected = (EObject) dialog.getFirstResult();
		}
		return selected;
	}
}
